package org.tysite.tyservice.example.jsonview.dto;

import com.fasterxml.jackson.annotation.JsonView;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import org.tysite.tyservice.example.jsonview.dto.serializer.JsonViewAttributeListSerializer;
import org.tysite.tyservice.example.jsonview.dto.serializer.JsonViewTypeSerializer;

import java.io.Serializable;
import java.util.List;

/**
 * JsonView 演示DTO
 * @author tysite
 * @date 2020/4/1 0001
 */
public class JsonViewInfoDTO implements Serializable {
    private static final long serialVersionUID = 8710245147814712925L;
    
    public interface ListView {}
    public interface DetailView extends ListView{}
    
    /** 数字字段 */
    @JsonView({ListView.class})
    private Integer id;
    /** 名称字段 */
    @JsonView({ListView.class})
    private String name;
    /** 密码字段 */
    @JsonView({DetailView.class})
    private String password;
    /** 对象字段 */
    @JsonView({ListView.class})
    @JsonSerialize(using = JsonViewTypeSerializer.class)
    private JsonViewTypeDTO type;
    /** 对象列表字段 */
    @JsonView({ListView.class})
    @JsonSerialize(using = JsonViewAttributeListSerializer.class)
    private List<JsonViewAttributeDTO> attribute;
    
    public Integer getId() {
        return id;
    }
    
    public void setId(Integer id) {
        this.id = id;
    }
    
    public String getName() {
        return name;
    }
    
    public void setName(String name) {
        this.name = name;
    }
    
    public String getPassword() {
        return password;
    }
    
    public void setPassword(String password) {
        this.password = password;
    }
    
    public JsonViewTypeDTO getType() {
        return type;
    }
    
    public void setType(JsonViewTypeDTO type) {
        this.type = type;
    }
    
    public List<JsonViewAttributeDTO> getAttribute() {
        return attribute;
    }
    
    public void setAttribute(List<JsonViewAttributeDTO> attribute) {
        this.attribute = attribute;
    }
    
    @Override
    public String toString() {
        return "JsonViewInfoDTO{" +
            "id=" + id +
            ", name='" + name + '\'' +
            ", type=" + type +
            ", attribute=" + attribute +
            '}';
    }
}